using System.Threading;

namespace DesignPattern.Creational.Singleton
{
    public class SingletonByStatic
    {
        private static SingletonByStatic _instance;
        private static int _createrThreadId;

        static SingletonByStatic()
        {
            _instance = new SingletonByStatic();
            _createrThreadId = Thread.CurrentThread.ManagedThreadId;
        }

        private SingletonByStatic() {}

        public static SingletonByStatic GetInstance()
        {
            return _instance;
        }

        public void ShowCreater()
        {
            System.Console.WriteLine($"This Singleton instance is created by {_createrThreadId}");
        }
    }
}